import request from '@/utils/request'

// 获取采集器信息
export function getInfo() {
  return request({
    url: '/device/face_lock',
    method: 'get',
  })
}

export function getList(data) {
  return request({
    url: '/device/face_lock/list',
    method: 'get',
    params: data
  })
}

// 添加
export function add(data) {
  return request({
    url: '/device/face_lock',
    method: 'post',
    data: data
  })
}

// 编辑
export function edit(data) {
  return request({
    url: '/device/face_lock',
    method: 'put',
    data: data
  })
}

export function getSelect(data) {
  return request({
    url: '/device/face_lock/select',
    method: 'get',
    params: data
  })
}

export function openDoor(faceLockId) {
  return request({
    url: `/device/face_lock/open-door/${faceLockId}`,
    method: 'post'
  })
}

export function syncPerson(faceLockId) {
  return request({
    url: `/device/face_lock/sync-person/${faceLockId}`,
    method: 'post'
  })
}

export function getPersons(faceLockId) {
  return request({
    url: `/device/face_lock/get-person-all/${faceLockId}`,
    method: 'get'
  })
}

export function getRenterList(faceLockId) {
  return request({
    url: `/device/face_lock/get-renders/${faceLockId}`,
    method: 'get'
  })
}

export function removeRenter(data) {
  return request({
    url: `/device/face_lock/remove-renter`,
    method: 'post',
    data: data
  })
}

// 获取未绑定的门禁设备列表
export function getUnbindList(roomId) {
  return request({
    url: `/device/face_lock/unbind-list/${roomId}`,
    method: 'get'
  })
}

// 绑定门禁设备到房间
export function bindRoom(faceLockId, roomIds) {
  return request({
    url: `/device/face_lock/bind-room/${faceLockId}`,
    method: 'post',
    params: { 
      roomIds: roomIds
    }
  })
}

// 解绑房间的门禁设备
export function unbindRoom(faceLockId, roomId) {
  return request({
    url: `/device/face_lock/unbind-room/${faceLockId}/${roomId}`,
    method: 'delete'
  })
}

// 获取门禁已绑定的房间列表
export function getBoundRooms(faceLockId) {
  return request({
    url: `/device/face_lock/bound-rooms/${faceLockId}`,
    method: 'get'
  })
}

// 获取门禁未绑定的房间列表
export function getUnboundRooms(faceLockId, params) {
  return request({
    url: `/device/face_lock/unbound-rooms/${faceLockId}`,
    method: 'get',
    params
  })
}

// 批量解绑房间
export function batchUnbindRoom(data) {
  return request({
    url: '/device/face_lock/batch-unbind-room',
    method: 'delete',
    data
  })
}

// 批量绑定房间
export function batchBindRoom(faceLockId, roomIds) {
  return request({
    url: `/device/face_lock/bind-room/${faceLockId}`,
    method: 'post',
    params: {
      roomIds
    }
  })
}

export default {
  getInfo,
  add,
  edit,
  getList,
  openDoor,
  syncPerson,
  getPersons,
  getRenterList,
  removeRenter,
  getSelect,
  getUnbindList,
  bindRoom,
  unbindRoom,
  getBoundRooms,
  getUnboundRooms,
  batchUnbindRoom,
  batchBindRoom
}